package com.shengzai.mapreduce.salarycount;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * ①使用MapReduce完成各部门中人员年成本总和
 * 	人员成本包括： 月工资和年终奖
 */
public class MapSalaryCount extends Mapper<LongWritable, Text,Text,IntWritable> {
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, IntWritable>.Context context) throws IOException, InterruptedException {
        String[] split = value.toString().split(",");
        String eName = split[1];
        if ("".equals(split[6])){
            split[6]="0";
        }
        int comm  = Integer.parseInt(split[5])*12 +Integer.parseInt(split[6]);
        context.write(new Text(eName),new IntWritable(comm));
    }
}
